home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / cmds / pmake / lst / RCS / lstPrev.c,v < prev    next >
Encoding:
Text File  |  1992-05-19  |  2.3 KB  |  102 lines

  1. head     1.8;
  2. branch   ;
  3. access   ;
  4. symbols  ;
  5. locks    ; strict;
  6. comment  @ * @;
  7.  
  8.  
  9. 1.8
  10. date     88.11.17.20.53.54;  author adam;  state Exp;
  11. branches ;
  12. next     ;
  13.  
  14.  
  15. desc
  16. @@
  17.  
  18.  
  19.  
  20. 1.8
  21. log
  22. @checked in with -k by kupfer at 92.05.18.17.32.46.
  23. @
  24. text
  25. @/*-
  26.  * LstPrev.c --
  27.  *    Get the node previous to the current one in the list and make it the
  28.  *    current node.
  29.  *    The sequential functions access the list in a slightly different way.
  30.  *    CurPtr points to their idea of the current node in the list and they
  31.  *    access the list based on it. Because the list is circular, Lst_Next
  32.  *    and Lst_Prev will go around the list forever. Lst_IsAtEnd must be
  33.  *    used to determine when to stop.
  34.  *
  35.  * Copyright (c) 1988 by University of California Regents
  36.  *
  37.  * Permission to use, copy, modify, and distribute this
  38.  * software and its documentation for any purpose and without
  39.  * fee is hereby granted, provided that the above copyright
  40.  * notice appears in all copies.  Neither the University of California nor
  41.  * Adam de Boor makes any representations about the suitability of this
  42.  * software for any purpose.  It is provided "as is" without
  43.  * express or implied warranty.
  44.  */
  45. #ifndef lint
  46. static char *rcsid =
  47. "$Id: lstPrev.c,v 1.8 88/11/17 20:53:54 adam Exp $ SPRITE (Berkeley)";
  48. #endif lint
  49.  
  50. #include    "lstInt.h"
  51.  
  52. /*-
  53.  *-----------------------------------------------------------------------
  54.  * Lst_Prev --
  55.  *    Return the node previous to the current one for the given list.
  56.  *
  57.  * Results:
  58.  *    The previous node or NILLNODE if the list hasn't been opened
  59.  *    yet or the beginning was reached.
  60.  *
  61.  * Side Effects:
  62.  *    the curPtr is changed to reflect reality.
  63.  *
  64.  *-----------------------------------------------------------------------
  65.  */
  66. LstNode
  67. Lst_Prev (l)
  68.     Lst                  l;
  69. {
  70.     register ListNode    tln;
  71.     register List     list = (List)l;
  72.     
  73.     if ((LstValid (l) == FALSE) ||
  74.     (list->isOpen == FALSE)) {
  75.         return (NILLNODE);
  76.     }
  77.     
  78.     list->prevPtr = list->curPtr;
  79.     
  80.     if (list->curPtr == NilListNode) {
  81.     if (list->atEnd == Unknown) {
  82.         list->curPtr = tln = list->lastPtr;
  83.         list->atEnd = Middle;
  84.     } else {
  85.         tln = NilListNode;
  86.         list->atEnd = Head;
  87.     }
  88.     } else {
  89.     tln = list->curPtr->prevPtr;
  90.     list->curPtr = tln;
  91.     if (tln == list->lastPtr || tln == NilListNode) {
  92.         list->atEnd = Head;
  93.     } else {
  94.         list->atEnd = Middle;
  95.     }
  96.     }
  97.     
  98.     return ((LstNode)tln);
  99. }
  100.  
  101. @
  102.